// https://www.luogu.com.cn/problem/P2758
#include <bits/stdc++.h>
using namespace std;
string s1, s2;
int main() {
    //freopen("in.in", "r", stdin);
    cin >> s1 >> s2;
    vector<vector<int>> dp(s1.size() + 1, vector<int>(s2.size() + 1));
    for(int i = 0; i <= s1.size(); i++) dp[i][0] = i;
    for(int j = 0; j <= s2.size(); j++) dp[0][j] = j;
    for(int i = 1; i <= s1.size(); i++) {
        for(int j = 1; j <= s2.size(); j++) {
            if(s1[i-1] == s2[j-1]) {
                dp[i][j] = dp[i-1][j-1];
            } else {
                dp[i][j] = min({dp[i-1][j]+1, dp[i][j-1]+1, dp[i-1][j-1]+1});
            }
        }
    }
    cout << dp[s1.size()][s2.size()] << endl;
    return 0;
}